import { getUserList } from '@/api/auth/user'
import { UserListParams, UserListRes } from '@/interface/auth/user'
import { PaginatedParams } from 'ahooks/lib/useAntdTable'
import { antdTableResult } from '@/interface/ahooks'

/**
 * @description: 定义useAntdTable第一个参数，调用获取表格数据接口
 * @param current 当前页
 * @param pageSize 每页条数
 * @param formData 表格参数
 * @return {*} 表格数据和total
 */
export const getUserData = async (
  { current, pageSize }: PaginatedParams[0],
  formData: UserListParams,
): Promise<antdTableResult<UserListRes>> => {
  const params = { ...formData }
  params.current = current
  params.size = pageSize
  const res: any = await getUserList(params)
  return {
    total: res.total,
    list: res.records,
  }
}
